package com.tmt.im.manager.config;


import com.tmt.im.common.yunxin.YunXinHelper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/27 13:38
 * @Version 1.0
 **/
@Configuration
public class RestTemplateConfig {

    @Bean("myRestTemplate")
    public RestTemplate restTemplate() {
        RestTemplate restTemplate = new RestTemplate(simpleClientHttpRequestFactory());
        YunXinHelper.restTemplate = restTemplate;
        return restTemplate;
    }

    @Bean
    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
        factory.setConnectTimeout(5000);
        // 设置代理
        //factory.setProxy(null);
        return factory;
    }
}
